<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="../template.xhtml" 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:t="http://myfaces.apache.org/tomahawk">

	<ui:define name="conteudo">		
		<a4j:keepAlive beanName="parteBean"/>
		
		<div style="width: 700px">
			<div style="float:left">
				<h2 style="margin: 0px">
					<h:outputText value="#{msg['parte.titulo.cadastrar']}" rendered="#{parteBean.parte.id == null}"/>
					<h:outputText value="#{msg['parte.titulo.editar']}" rendered="#{parteBean.parte.id != null}"/>
				</h2>
			</div>
		</div>
		
		<div style="height: 50px"></div>

		<rich:messages id="mensagemErro" layout="list" style="color: red; font-weight: bold;"/>
	    
		<h:selectOneRadio value="#{parteBean.tipoPessoaParte}">
	        <f:selectItem itemValue="PF" itemLabel="#{msg['parte.pessoa.fisica']}" />
	        <f:selectItem itemValue="PJ" itemLabel="#{msg['parte.pessoa.juridica']}"/>
	        <a4j:support event="onchange" reRender="campos"/>
	    </h:selectOneRadio>	    
	                
	    <h:panelGroup id="campos">
			<h:panelGrid columns="2" rendered="#{parteBean.tipoPessoaParte == 'PF'}">
				<h:outputLabel value="#{msg['geral.nome']}" />
				<h:inputText value="#{parteBean.partePessoaFisica.nome}" size="23"/>
				
				<h:outputLabel value="#{msg['geral.cpf']}" />
				<h:inputText value="#{parteBean.partePessoaFisica.cpf}" size="23"/>
			</h:panelGrid>
			<h:panelGrid columns="2" rendered="#{parteBean.tipoPessoaParte == 'PJ'}">
				<h:outputLabel value="#{msg['parte.razao.social']}" />
				<h:inputText value="#{parteBean.partePessoaJuridica.razaoSocial}" size="23"/>
				
				<h:outputLabel value="#{msg['geral.cnpj']}" />
				<h:inputText value="#{parteBean.partePessoaJuridica.cnpj}" size="23"/>
			</h:panelGrid>
		</h:panelGroup>
		
		<div style="height: 20px"></div>
		
		<div>
			<h:commandButton value="#{msg['geral.salvar']}" action="#{parteBean.salvar}" />
			<h:commandButton value="#{msg['geral.cancelar']}" action="manterParte"/>
		</div>		
	</ui:define>
</ui:composition>